<?php

echo "<title>Simplicity test using Wilson theorem</title>";

function issimple($var) {
    if ((factorial($var - 1) + 1) % $var == 0) {
        echo "<font color = red>Yep, " . $var . " is simple</font><br>";
    } else
        echo "No, " . $var . " is complex<br>";
}

function factorial($var) {
    return ($var <= 1) ? 1 : $var * factorial($var - 1);
}

for ($i = 2; $i <= 20; $i++) {
    issimple($i);
}
?>
